package com.hospital.pet.love.lovepethospital.controller;

import com.hospital.pet.love.lovepethospital.domain.Drug;
import com.hospital.pet.love.lovepethospital.dto.drug.AddDrugDto;
import com.hospital.pet.love.lovepethospital.dto.drug.RefillSuppliesDto;
import com.hospital.pet.love.lovepethospital.resp.Result;
import com.hospital.pet.love.lovepethospital.resp.ResultCodeEnum;
import com.hospital.pet.love.lovepethospital.service.DrugService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author RoselleShaw
 * @create 2024-05-10 14:05
 */
@RestController
@RequestMapping("/drug")
@Tag(name = "药品管理")
public class DrugController {

    @Resource
    private DrugService drugService;

    @PostMapping("/add")
    @Operation(summary = "录入药品消息")
    public Result<Void> add(@RequestBody AddDrugDto addDrugDto) {
        drugService.save(addDrugDto);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

    @GetMapping("/list")
    @Operation(summary = "药品信息列表")
    public Result<List<Drug>> list() {
        return Result.build(drugService.list(), ResultCodeEnum.SUCCESS);
    }

    @PostMapping("/refill-supplies")
    @Operation(summary = "补充库存")
    public Result<Void> refillSupplies(@RequestBody RefillSuppliesDto refillSuppliesDto){
        drugService.refillSupplies(refillSuppliesDto);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }

}
